Class Strings.DisplayString

A string appearing on the screen.

Can be used for subtitles and "2001, somewhere in Egypt"-style messages.

Uses screen-space coordinates, with x values specifying the number of pixels from the left of the window, and y values specifying the number of pixels from the top of the window.

Since different players will have different resolutions, you should work in terms of percentages where possible, and use ScreenToPercent and PercentToScreen when you need to use screen-space coordinates.

Functions

DisplayString(str, x, y, color, translated, flags) Create a DisplayString.
DisplayString:GetColor() Get the display string's color
DisplayString:SetColor(color) Set the display string's color
DisplayString:GetKey() Get the string key to use.
DisplayString:SetKey(string) Set the string key to use.
DisplayString:SetPosition(x, y) Set the position of the string.
DisplayString:GetPosition() Get the position of the string.
DisplayString:SetFlags(table) Set the display string's flags
DisplayString:SetTranslated(shouldTranslate) Set translated parameter of the string


Functions

DisplayString(str, x, y, color, translated, flags)
Create a DisplayString. For use in ShowString and HideString.

Parameters:

  • str string string to print or key of translated string
  • x int x-coordinate of top-left of string (or the center if DisplayStringOption.CENTER is given)
  • y int y-coordinate of top-left of string (or the center if DisplayStringOption.CENTER is given)
  • color Color the color of the text
  • translated bool if false or omitted, the str argument will be printed. If true, the str argument will be the key of a translated string specified in strings.lua. Default: false.
  • flags table a table of display options. Can be empty or omitted. The possible values and their effects are...

    TEN.Strings.DisplayStringOption.CENTER -- see x and y parameters
    TEN.Strings.DisplayStringOption.SHADOW -- will give the text a small shadow
    

    Default: empty

Returns:

    DisplayString A new DisplayString object.
DisplayString:GetColor()
Get the display string's color

Returns:

    Color a copy of the display string's color
DisplayString:SetColor(color)
Set the display string's color

Parameters:

  • color Color the new color of the display string
DisplayString:GetKey()
Get the string key to use. If translated is true when DisplayString is called, this will be the string key for the translation that will be displayed. If false or omitted, this will be the string that's displayed.

Returns:

    string a string
DisplayString:SetKey(string)
Set the string key to use. If translated is true when DisplayString is called, this will be the string key for the translation that will be displayed. If false or omitted, this will be the string that's displayed.

Parameters:

  • string string the new key for the display string
DisplayString:SetPosition(x, y)
Set the position of the string. Screen-space coordinates are expected.

Parameters:

  • x int x-coordinate of the string
  • y int y-coordinate of the string
DisplayString:GetPosition()
Get the position of the string. Screen-space coordinates are returned.

Returns:

  1. int x x-coordinate of the string
  2. int y y-coordinate of the string
DisplayString:SetFlags(table)
Set the display string's flags

Parameters:

  • table table the new table with display flags options

Usage:

    local varDisplayString = DisplayString('example string', 0, 0, Color(255, 255, 255), false)
    possible values:
    varDisplayString:SetFlags({})
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.CENTER })
    varDisplayString:SetFlags({ TEN.Strings.DisplayStringOption.SHADOW, TEN.Strings.DisplayStringOption.CENTER })
    -- When passing a table to a function, you can omit the parentheses
    varDisplayString:SetFlags{ TEN.Strings.DisplayStringOption.CENTER }
DisplayString:SetTranslated(shouldTranslate)
Set translated parameter of the string

Parameters:

  • shouldTranslate bool if true, the string's key will be used as the key for the translation that will be displayed. If false, the key itself will be displayed
generated by TEN-LDoc (a fork of LDoc 1.4.6) Last updated 2023-06-03 11:42:57